package com.uenpay.im.ui.old.activity.bankcard;

import com.qiyunxin.android.http.utils.StringUtils;
import com.qiyunxin.android.http.utils.Utils;
import com.qyx.android.utilities.DateUtils;
import com.uenpay.im.IMApplication;
import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 删除银行卡
 *
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class DeleteBankCardNumInvokeItem extends BaseHttpInvokeItem {
	public class DeleteBankCardNumInvokeItemResult extends HttpInvokeResult {
	}

	public DeleteBankCardNumInvokeItemResult getOutPut() {
		return (DeleteBankCardNumInvokeItemResult) GetResultObject();
	}

	public DeleteBankCardNumInvokeItem(String bankcard, String paypassword) {
		String time = DateUtils.getCurrentSeconds() + "";
		String sign = Utils.md5(Utils.md5(IMApplication.getUserMobilePhone()
				+ "_" + time));
		String url = APIConfiguration.getBaseUrl()
				+ "Purse/Purse/unbindBankCard?bankcard="
				+ StringUtils.encodeParams(bankcard) + "&paypassword="
				+ paypassword + "&time=" + time + "&sign=" + sign + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		DeleteBankCardNumInvokeItemResult result = new DeleteBankCardNumInvokeItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");
		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}

		return result;
	}

}
